/*
 * Copyright 2010-2011 CGT&DC ISA RAS
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package websolve.workflow.runtime;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestRegex {

    /**
     * @param args
     */
    public static void main(String[] args) {

        // String codeText = "test.diamond.TaskA ( in ) : { out1 , out2 } ";
        // Pattern namePattern = Pattern.compile("^[ ]*(\\w*)[ ]*\\(.*");

        String codeText = " test.diamond.TaskA ( in ) : { out1 , out2 } ";
        Pattern namePattern = Pattern.compile("^[ ]*([\\w\\.]*)[ ]*\\(");

        Matcher nameMatcher = namePattern.matcher(codeText);

        boolean found = false;
        while (nameMatcher.find()) {

            System.out.println(nameMatcher.group(1));

            found = true;
        }
        if (!found) {
            System.out.println("No match found.%n");

        }

        Pattern inputPattern = Pattern.compile("^[ ]*[\\w\\.]*[ ]*\\([ ]*(.*)[ ]*\\)");
        Matcher inputMatcher = inputPattern.matcher(codeText);

        found = false;
        while (inputMatcher.find()) {

            System.out.println(inputMatcher.group(1));

            found = true;
        }
        if (!found) {
            System.out.println("No match found.%n");

        }
        Pattern outputPattern = Pattern.compile("^[ ]*[\\w\\.]*[ ]*\\([ ]*.*[ ]*\\)[ ]*:[ ]*\\{[ ]*(.*)[ ]*\\}");
        Matcher outputMatcher = outputPattern.matcher(codeText);

        found = false;
        while (outputMatcher.find()) {

            System.out.println(outputMatcher.group(1));

            found = true;
        }
        if (!found) {
            System.out.println("No match found.%n");

        }

    }

}